package com.online.music.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.online.music.common.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

import com.online.music.service.ISongPlaylistService;
import com.online.music.entity.po.SongPlaylist;

import org.springframework.web.bind.annotation.RestController;


/**
 * @Author: Leno
 * @Date: 2025-01-31
 * @Description: songPlaylist接口
 */
@RequiredArgsConstructor
@Slf4j
@Tag(name = "songPlaylist接口")
@RestController
@RequestMapping("/song-playlist")
public class SongPlaylistController {

    private final ISongPlaylistService songPlaylistService;

    @Operation(summary = "查询所有SongPlaylist")
    @GetMapping
    public Result<List<SongPlaylist>> findAll() {
        return Result.success(songPlaylistService.list());
    }

    @Operation(summary = "根据id查询SongPlaylist")
    @GetMapping("/{id}")
    public Result<SongPlaylist> findOne(@PathVariable Long id) {
        return Result.success(songPlaylistService.getById(id));
    }

    @Operation(summary = "根据分页查询SongPlaylist")
    @GetMapping("/page")
    public Result<Page<SongPlaylist>> findPage(@RequestParam Integer pageNum, @RequestParam Integer pageSize,
                                               SongPlaylist songPlaylist) {
        return songPlaylistService.findPage(pageNum, pageSize, songPlaylist);
    }

    @Operation(summary = "添加或修改SongPlaylist")
    @PostMapping
    public Result<Boolean> save(@RequestBody SongPlaylist songPlaylist) {
        return Result.success(songPlaylistService.saveOrUpdate(songPlaylist));
    }

    @Operation(summary = "根据id批量删除SongPlaylist")
    @DeleteMapping("/del/batch")
    public Result<String> deleteBatch(@RequestBody List<Long> ids) {
        return songPlaylistService.deleteBatch(ids);
    }

}
